﻿using System;
using System.Data;
using System.Web.UI;

namespace DataList的使用
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindDataList();
            }
        }

        protected void BindDataList()
        {
            string commandText =
                @"SELECT StudentID, Student2.Name, Department.Name AS DepartmentName, Photo, Gender, Address, DayOfBirth 
                    FROM Student2 INNER JOIN Department ON Student2.Department = Department.DepartmentID";
            DataSet dataSet = SqlHelper.GetDataSetBySqlCommand(commandText, SqlHelper.GetConnection());
            DataList1.DataSource = dataSet;
            DataList1.DataBind();
        }
    }
}